import { getGameObjectById } from "../engine";
import { Behaviour } from "../engine/Behaviour";
import { TextRenderer } from "../engine/TextRenderer";
import { Transform } from "../engine/Transform";
import { number } from "../engine/validators/number";
import { Display } from "./Display";
import { ItemSpeed } from "./ItemSpeed";

let speed:number;

export class OrderFinishedClicked extends Behaviour {
   // private currentSpeed=0;
   // @number()
   // speed = 5;

    onStart() {
        let sum:number;
        let income:number;
        let time:string;
        let cost:number;
        let rental=20;
        let fee:number;
        let profit:number;
        let order:string;

        this.gameObject.onClick = () => {
             console.log(this.gameObject.id);
             order=getGameObjectById('UI_dialog_requirement').getBehaviour(TextRenderer).text;
             time=getGameObjectById('UI_time_text').getBehaviour(TextRenderer).text;
             income=Number(getGameObjectById('Text_Income').getBehaviour(TextRenderer).text);
             sum=Number(getGameObjectById('UI_money_text').getBehaviour(TextRenderer).text);
             cost=Number(getGameObjectById('Text_cost').getBehaviour(TextRenderer).text);
             fee=Number(getGameObjectById('Text_Fee').getBehaviour(TextRenderer).text);
             profit=Number(getGameObjectById('Text_profit').getBehaviour(TextRenderer).text);

             switch(order){
                case "来一份经典原味的烤冷面！":{
                    sum+=7;
                    income+=7;
                    profit=(income+fee)-(cost+rental);
                    break;
                }

                case "老板，我要一个经典加肠烤冷面。":{
                    sum+=9;
                    income+=9;
                    profit=(income+fee)-(cost+rental);
                    break;
                }

                case "来份火辣辣烤冷面！":{
                    sum+=8;
                    income+=8;
                    profit=(income+fee)-(cost+rental);
                    break;
                }

                case "我要一个加鸡柳烤冷面。":{
                    sum+=10;
                    income+=10;
                    profit=(income+fee)-(cost+rental);
                    break;
                }

                case "我要一个烤冷面加培根。":{
                    sum+=8;
                    income+=8;
                    profit=(income+fee)-(cost+rental);
                    break;
                }

             }
             
             getGameObjectById('Text_Income').getBehaviour(TextRenderer).text=String(income);
             getGameObjectById('UI_money_text').getBehaviour(TextRenderer).text=String(sum);
             getGameObjectById('Text_cost').getBehaviour(TextRenderer).text=String(cost);
             getGameObjectById('Text_profit').getBehaviour(TextRenderer).text=String(profit);


            
             /*if(time=="24：00"){
                console.log("弹出账单");
                getGameObjectById('UI_Bill').getBehaviour(Display).IsActive=true;
                getGameObjectById('Text_day_number').getBehaviour(Display).IsActive=true;
                getGameObjectById('Text_Income').getBehaviour(Display).IsActive=true;
                getGameObjectById('Text_Fee').getBehaviour(Display).IsActive=true;
                getGameObjectById('Text_Rental').getBehaviour(Display).IsActive=true;
                getGameObjectById('Text_cost').getBehaviour(Display).IsActive=true;
                getGameObjectById('Text_profit').getBehaviour(Display).IsActive=true;
                getGameObjectById('UI_Button_Nextday').getBehaviour(Display).IsActive=true;
              
             }*/
             
        };
    }

    onTick(duringTime: number) {

    }
}
